package com.wejoy.video.middle.station.admin;

import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

class Dept {
    String category;
    Double longitude;
    Double latitude;
    Integer departmentId;
    
    // 构造函数，getters，setters等...
}

public class ExcelReader {

    public static List<Dept> readDeptData(String filePath) throws IOException {
        List<Dept> depts = new ArrayList<>();

        FileInputStream inputStream = new FileInputStream(filePath);
        Workbook workbook = new XSSFWorkbook(inputStream);
        Sheet firstSheet = workbook.getSheetAt(0);
        Iterator<Row> rowIterator = firstSheet.iterator();

        while (rowIterator.hasNext()) {
            Row nextRow = rowIterator.next();

            Dept dept = new Dept();
            dept.category = nextRow.getCell(0).getStringCellValue(); // 假设第一列是类别
            dept.longitude = nextRow.getCell(1).getNumericCellValue(); // 假设第二列是经度
            dept.latitude = nextRow.getCell(2).getNumericCellValue(); // 假设第三列是纬度
            dept.departmentId = (int)nextRow.getCell(3).getNumericCellValue(); // 假设第四列是部门ID

            depts.add(dept);
        }

        workbook.close();
        inputStream.close();

        return depts;
    }

    // main 方法或其他调用 readDeptData 方法的地方...
}